package com.dubbo.framework.balance;

import cn.hutool.core.util.RandomUtil;
import com.dubbo.framework.URL;

import java.util.List;
import java.util.Random;

/**
 * 随机
 *
 * @author by Mr. Li 2021/4/29 15:19
 */
public class RandomLoadBalance implements LoadBalance {

    @Override
    public URL load(List<URL> list) {
        assert list.size() != 0;

        final int i = RandomUtil.randomInt(0, list.size());

        return list.get(i);
    }
}
